package com.beauty.dressing.module.mine.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.beauty.dressing.common.bean.BaseBean;
import com.beauty.dressing.common.bean.StringBase;
import com.beauty.dressing.module.common.adapter.CommonExpandWrapperAdapter;
import com.beauty.dressing.module.market.holder.ShopDetilImageHolder;

public class IntegralAdapter extends CommonExpandWrapperAdapter {

    private static final int VIEW_TYPE_IMAGE = 1;//内容

    public IntegralAdapter(Context context) {
        super(context);
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        RecyclerView.ViewHolder viewHolder = null;
        if (isHeader(viewType) || isFooter(viewType)) {
            viewHolder = super.onCreateViewHolder(viewGroup, viewType);
        } else {
            viewHolder = new ShopDetilImageHolder(mContext, mLayoutInflater, viewGroup);
        }
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ShopDetilImageHolder) {
            ((ShopDetilImageHolder) holder).bindData(getItem(position), position);
        }
    }

    @Override
    public int getItemViewType(int position) {
        int type;
        BaseBean bean = getItem(position);
        if (bean instanceof FixedViewInfo) {
            type = ((FixedViewInfo) bean).viewType;
        } else if (bean instanceof StringBase) {
            type = VIEW_TYPE_IMAGE;
        } else {
            type = super.getItemViewType(position);
        }
        return type;
    }
}
